package calao.plan.client;

import java.util.Date;

import com.google.gwt.user.client.rpc.IsSerializable;

public class Task
implements IsSerializable
{
		
	int id;
	long start;
	long end;
	int doer;
	int workTime; // in minutes
	int[] dependencies = {}; // tasks that must be finished to start this task
	int priority;
	boolean startFixed = false;
	boolean endFixed = false;
		
	public Task() {}
	
	public Task(int id)
	{
		this.id = id;
	}
	
	public Task(Task task)
	{
		id = task.id;
		start = task.start;
		end = task.end;
		doer = task.doer;
		workTime = task.workTime;
		dependencies = task.dependencies;
		priority = task.priority;
		startFixed = task.startFixed;
		endFixed = task.endFixed;
	}
	
	public void setId(int id)
	{
		this.id = id;
	}
	
	public int getId()
	{
		return id;
	}
	
	public int[] getDependencies()
	{
		return dependencies;
	}
	
	public void setDependencies(int[] taskIds)
	{
		this.dependencies = taskIds;
	}
			
	public long getStart()
	{
		return start;
	}
	
	public Date getStartDate()
	{
		return start>0? new Date(start) : null;
	}
	
	public void setStart(long time)
	{
		this.start = time;
	}
		
	public long getEnd()
	{
		return end;
	}
	
	public Date getEndDate()
	{
		return end>0? new Date(end) : null;
	}

	public void setEnd(long time)
	{
		this.end = time;
	}

	public void setDoer(int resourceId)
	{
		this.doer = resourceId;
	}
	
	public int getDoer()
	{
		return doer;
	}
	
	public int getPriority()
	{
		return priority;
	}
	
	public void setPriority(int pri)
	{
		this.priority = pri;
	}
	
	public int getWorkTime()
	{
		return workTime;
	}
	
	public void setWorkTime(int minutes)
	{
		this.workTime = minutes;
	}

	public boolean isStartFixed() 
	{
		return startFixed;
	}

	public void setStartFixed(boolean fixed) 
	{
		this.startFixed = fixed;
	}

	public boolean isEndFixed() 
	{
		return endFixed;
	}

	public void setEndFixed(boolean fixed) 
	{
		this.endFixed = fixed;
	}
	
}
